package com.msmall.community.common.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.WebApplicationContext;

import com.msmall.community.ApplicationManager;
import com.msmall.community.common.CommunityInitialize;


public class InitListener implements ServletContextListener {
	
	private static final Log logger = LogFactory.getLog(InitListener.class);
	
	public void contextInitialized(ServletContextEvent sce) {
		ApplicationManager.appContext = (WebApplicationContext)(sce.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
		try {
			CommunityInitialize.refresh();
		} catch (Exception e) {
			logger.error(e);
		}
		logger.info("System load well");
	}
	
	public void contextDestroyed(ServletContextEvent sce) {
	}

}
